import store from '@/store'

import router from '@/router'

export function isGetToken () {
  //  获取vuex里面的token  
  if (!store.state.token) {
    let token = localStorage.getItem('token')
    if (!token) {
      // 跳转到登录
      // router.repalce('/login')
      alert('先登录')
    } else {
      store.commit('setToken', token)
    }

  }

}


export function setLocalToken (token) {
  localStorage.setItem('token', token)

}
export function getLocalToken () {
  let res = localStorage.getItem('token') || ''
  return res

}
export function clearToken () {
  localStorage.removeItem('token')

}